package com.example.mvp.adapter.holder

import android.support.v7.widget.RecyclerView
import android.view.View

/**
 * @author  chaohaipeng  on 2018/8/13.
 */
class BaseViewHolder( itemView:View,itemTypes:Int) : RecyclerView.ViewHolder(itemView) {
    private var rootView:View=itemView
    private var itemType:Int=itemTypes

    init {
        if (itemType==1){


        }else{

        }
    }

    fun setOnClickListener(listener: View.OnClickListener, vararg ids: Int) {
        if (ids == null) {
            return
        }
        for (id in ids) {
            if (null == getView(id)) {
                continue
            }
            getView<View>(id)!!.setOnClickListener(listener)
        }
    }

    private fun <T : View> bindView(id: Int): T? {
        if ( null == rootView) {
            return null
        }
           val view = rootView.findViewById<T>(id)
        return view
    }

    fun <T : View> getView(id: Int): T? {
        return bindView<View>(id) as T?
    }
}